package com.weactivity.mapper;

import com.weactivity.dto.FeedbackDTO;
import com.weactivity.entity.Feedback;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FeedbackMapper {

    @Insert("insert into feedback(uid, aid, evaluate_a, evaluate_m, evaluate_o, advice, time) value "+
    "(#{uid},#{aid},#{evaluateA},#{evaluateM},#{evaluateO},#{advice},#{time})")
    void insert(Feedback feedback);

    @Select("select AVG(evaluate_a) from feedback where aid=#{aid}")
    int FindEvaAByAid(int aid);

    @Select("select AVG(evaluate_m) from feedback where aid=#{aid}")
    int FindEvaMByAid(int aid);

    @Select("select AVG(evaluate_o) from feedback where aid=#{aid}")
    int FindEvaOByAid(int aid);

    @Select("select * from feedback where aid = #{aid}")
    List<FeedbackDTO> SelectByAid(int aid);

    @Select("select COUNT(*) from user_activity_role where aid = #{aid}")
    int findTotalNumByAid(int aid);

    @Select(("select COUNT(DISTINCT uid) from feedback where aid = #{aid}" ))
    int findNumByAid(int aid);

    @Select("select uid from activity_organizer where aid = #{aid}")
    int findOrganByAid(int aid);

    @Select("select uid from activity_manager where aid = #{aid}")
    int findManByAid(int aid);
}
